package eu.dominicum.pno.ui.jfx;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.stage.Stage;

import java.io.IOException;

public class Main extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {

        Parent root;
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("pno-main.fxml"));
        try {
            root = (Parent) fxmlLoader.load();
        } catch (IOException e) {
            throw new IllegalStateException("Unable to load FXML file for PNO");
        }

        Scene scene = new Scene(root);
        TreeView accountsTreeView = (TreeView) fxmlLoader.getNamespace().get("accountsTree");
        TreeItem<String> rootItem = new TreeItem<>("Accounts");
        accountsTreeView.setRoot(rootItem);
        primaryStage.setTitle("PNO");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
